<?php
require_once "db_login_constants.php";
class Login_DB {
  private $connection = NULL;
  private $result = NULL;
  private $counter=NULL;
 
  private $dbconfig = array(
			'server' => LOGIN_SERVER,
			'user' => LOGIN_USER,
			'password' => LOGIN_PASS,
			'database' => LOGIN_NAME,
			);
 
  public function __construct(){
  	//print_r( $this->dbconfig);
	$this->connection = mysql_connect($this->dbconfig['server'],
                                      $this->dbconfig['user'],
                                      $this->dbconfig['password'],
                                      TRUE);	
  	mysql_select_db($this->dbconfig['database'], $this->connection);
  }
 
  public function disconnect() {
    if (is_resource($this->connection===true))
        mysql_close($this->connection);
  }
 
  public function query($query) {
  	$this->result=mysql_query($query,$this->connection)or die("DB Error occurred:".$query."<br />".mysql_error()."[".mysql_errno()."]");
  	$this->counter=NULL;
  }
 
  public function fetchRow() {
  	return mysql_fetch_assoc($this->result);
  }
 
 
  public function count() {
  	if($this->counter===NULL && is_resource($this->result)===true) {
  		$this->counter=mysql_num_rows($this->result);
  	}
 
	return $this->counter;
  }
}

?>